"""
@File    :   router.py
@Time    :   2024/04/20 18:31:10
@Author  :   Qrj
@Email   :   923207736@qq.com
@description   :   租户系统配置路由
"""

from typing import Annotated

from fastapi import APIRouter, Depends

from src.business.admin.system.oauth2.token.dependencies.no_introduction import (
    DependVerifyAccessTokenMenumPermission,
)
from src.enums.permission_operation import PermissionOperationEnum
from src.utils.unified_response import SuccessApiJSONResponse

from .dependencies.route_depend import (
    route_depend_get_system_settings,
    route_depend_update_system_settings,
)
from .schemas.out import SystemSettingsCompleteOutSchema

# 构建权限验证相关的依赖项
# 查
depend_select_permission_verify = DependVerifyAccessTokenMenumPermission(
    __file__, PermissionOperationEnum.select.value
)
# 改
depend_update_permission_verify = DependVerifyAccessTokenMenumPermission(
    __file__, PermissionOperationEnum.update.value
)

# 创建路由
router = APIRouter(
    prefix="/admin/system/settings",
    tags=[
        "后台租户系统配置接口",
    ],
)


@router.get("/get", summary="查询单个租户系统配置")
async def route_get_tenant_settings(
    verify_menu_permission: Annotated[None, Depends(depend_select_permission_verify)],
    tenant_settings: Annotated[
        SystemSettingsCompleteOutSchema, Depends(route_depend_get_system_settings)
    ],
):
    return SuccessApiJSONResponse(data=tenant_settings)


@router.post("/update", summary="修改租户系统配置")
async def route_update_user(
    verify_menu_permission: Annotated[None, Depends(depend_update_permission_verify)],
    update_operation: Annotated[None, Depends(route_depend_update_system_settings)],
):
    return SuccessApiJSONResponse()
